<template>
    <el-card>
      <div slot="header" class="clearfix">
        <h4>报废申请单-查看</h4>
      </div>
      <el-row>
        <skus-table
          :table-height="500"
          :data-source="tableInfo.list"
          :loading="tableInfo.loading"
          :columns="tableInfo.columns"
        />
      </el-row>
      <FooterFields :footerFields="viewdata" />
    </el-card>
</template>

<script>
import FooterFields from '@/pages/commodity/components/FooterFields';
import SkusTable from '@/components/skusTable';
import { getScrapRecordDetailService } from '@api/stock/stockOverflowRecord';
import { VIEW_TABLE_COLUMNS } from './constants';

export default {
  components: {
    FooterFields,
    SkusTable
  },
  data () {
    return {
      tableInfo: {
        list: [],
        columns: VIEW_TABLE_COLUMNS,
        loading: false
      },
      recordNo: '',
      viewdata: {}
    };
  },
  created () {
    this.recordNo = this.$route.query.recordNo;
    this.loadTableData();
  },
  methods: {
    async loadTableData () {
      const res = await getScrapRecordDetailService(this.recordNo, state => { this.tableInfo.loading = state })
      if (res) {
        const { detailList, recordInfo } = res.retData;
        this.tableInfo.list = detailList;
        this.viewdata = recordInfo;
      }
    }
  }
};
</script>
